#include <iostream>
#include <string>
#include <vector>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <memory>
#include <functional>
#include <ctime>
using work_t = std::function<void()>;
enum
{
    OK = 0,
    FORKERR,
    USAGEERR,
    PIPEERR,
    WRITERR,
    READERR
};
#include "Channel.hpp"
#include "Task.hpp"
#include "processpool.hpp"


void Usage(std::string str)
{
    std::cout << "Usage，" << str << " process-num" << std::endl;
}
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(USAGEERR);
    }

    int num = std::stoi(argv[1]); // 需要创建的进程个数
    std::unique_ptr<processpool> pp = std::make_unique<processpool>(num);
    //初始化进程池
    pp->Init();
    //派发任务
    //pp->Dispatch();
    sleep(100);
    //关闭进程池
    pp->CloseProcesspool();

    //sleep(100);

    return 0;
}